import Mock from 'mockjs'
import { obj } from '../carts/index.js'
import { userId } from '../user/index.js'

Mock.mock('/api/orders', 'post', {
  "status|1": [0, 1],
  "data": {
    "orderNo": 1485158223095,
    "payment": 2999.11,
    "paymentType": 1,
    "postage": 0,
    "status": 10,
    "paymentTime": null,
    "sendTime": null,
    "endTime": null,
    "closeTime": null,
    "createTime": new Date().getTime(),
    "orderItemVoList": [
      {
        "orderNo": 1485158223095,
        "productId": 2,
        "productName": "oppo R8",
        "productImage": "mainimage.jpg",
        "currentUnitPrice": 2999.11,
        "quantity|1-5": 1,
        "totalPrice": 2999.11,
        "createTime": null
      }
    ],
    "shippingId": 5,
    "shippingVo": null
  }
})
Mock.mock('/api/orders', 'get', {
  "status": 0,
  "data": {
    "pageNum": 1,
    "pageSize": 3,
    "size": 3,
    "orderBy": null,
    "startRow": 1,
    "endRow": 3,
    "total": 16,
    "pages": 6,
    "list|1-3": [
      {
        "orderNo": 1485158676346,
        "payment": 2999.11,
        "paymentType": 1,
        "paymentTypeDesc": "在线支付",
        "postage": 0,
        "status": 10,
        "statusDesc": "未支付",
        "paymentTime": new Date().getTime(),
        "sendTime": new Date().getTime(),
        "endTime": new Date().getTime(),
        "closeTime": new Date().getTime(),
        "createTime": new Date().getTime(),
        "orderItemVoList": obj.data['cartProductVoList|1-5'],
        "imageHost": "http://img.happymmall.com/",
        "shippingId": 5,
        "receiverName": "geely",
        "shippingVo": null
      }
    ],
    "firstPage": 1,
    "prePage": 0,
    "nextPage": 2,
    "lastPage": 6,
    "isFirstPage": true,
    "isLastPage": false,
    "hasPreviousPage": false,
    "hasNextPage|1": true,
    "navigatePages": 8,
    "navigatepageNums": [
      1,
      2,
      3,
      4,
      5,
      6
    ]
  }
})
Mock.mock('/api/orders/10', 'get', {
  "status": 0,
  "data": {
    "orderNo": 1480515829406,
    "payment": obj.data['cartProductVoList|1-5'].reduce((prev, cur) => prev + cur.productTotalPrice, 0),
    "paymentType": 1,
    "paymentTypeDesc": "在线支付",
    "postage": 0,
    "status|1": [10, 20],
    "statusDesc": "未支付",
    "paymentTime": "",
    "sendTime": "",
    "endTime": "",
    "closeTime": "",
    "createTime": "2016-11-30 22:23:49",
    "orderItemVoList": obj.data['cartProductVoList|1-5'],
    "imageHost": "http://img.happymmall.com/",
    "shippingId": 3,
    "receiverName": "geely",
    "shippingVo": [
      {
        "id": 4,
        "userId": userId,
        "receiverName|1": ["河畔一角", "AAA"],
        "receiverPhone": "010",
        "receiverMobile": "18688888888",
        "receiverProvince": "北京",
        "receiverCity": "北京市",
        "receiverDistrict": "海淀区",
        "receiverAddress": "中关村",
        "receiverZip": "100000",
        "createTime": new Date().getTime(),
        "updateTime": new Date().getTime()
      },
      {
        "id": 5,
        "userId": userId,
        "receiverName|1": ["河畔一角", "AAA"],
        "receiverPhone": "010",
        "receiverMobile": "18688888888",
        "receiverProvince": "北京",
        "receiverCity": "北京市",
        "receiverDistrict": "海淀区",
        "receiverAddress": "中关村",
        "receiverZip": "100000",
        "createTime": new Date().getTime(),
        "updateTime": new Date().getTime()
      }
    ]
  }
})
Mock.mock('/api/orders/10', 'put', {
  "status|1": [0, 1]
})